<template>
    <div class="wait-time">
        <div class="wait-time-left">
            <b class="fl">免费等待时长</b> <span class="fl" v-text="time">14:56:40</span>
        </div>
        <div class="wait-time-right">
            <button class="border-outline opacity" type="button" @click="cancelOrder()">取消订单</button>
        </div>
    </div>
</template>

<script>
 export default {
    props: ["restSecond"],
    mounted () {
        console.log(this.restSecond);
        this.countDown(this.restSecond);
    },
    methods: {
        cancelOrder () {
            this.$emit("cancelValue", true);
        },
        countDown (num) {
            let _this = this,
            totalTime = num * 1000,
            timer = setInterval(() => {
                totalTime-=4;
                if (totalTime <= 0) {
                    clearInterval(timer);
                }
                this.minute = parseInt(totalTime/(60*1000));
                this.second = parseInt((totalTime%(60*1000))/1000);
                this.time = this.minute + " : " + this.second + " : " + totalTime%1000;
            }, 1);
        }
    },
    data () {
        return {
            time: "",
            hour: "",
            minute: "",
            second: "",
        }
    }
 }
</script>

<style scoped>
    .wait-time {
        width: 100%;
        height: 100px;
        position: absolute;
        top: 0;
        right: 0;
        z-index: 15;
        padding: 0 30px;
        text-align: left;

        background: #fff;
        box-shadow: 0 10px 20px 0 rgba(0,0,0,0.05);
    }
    /*左侧*/
    .wait-time-left {
        font-family: PingFangSC-Regular;
        font-size: 28px;
        color: #333;
        letter-spacing: 0;
    }
    .wait-time-left b {
        height: 40px;
        line-height: 40px;
        margin-top: 28px;
        font-weight: normal;

        font-family: PingFangSC-Regular;
        font-size: 28px;
        color: #333;
        letter-spacing: 0;
    }
    .wait-time-left  span {
        margin-top: 25px;
        margin-left: 24px;
        line-height: 50px;

        font-family: PingFangSC-Semibold;
        font-size: 36px;
        color: #0db95f;
        letter-spacing: 0;
    }
    /*右侧*/
    .wait-time-right {
        height: 100%;

        position: absolute;
        top: 0;
        right: 0;
    }
    .wait-time-right button {
        display: block;
        width: 180px;
        height: 60px;
        line-height: 60px;
        margin: 20px 30px;

        background: #f5f5f5;
        border-radius: 30px;

        font-family: PingFangSC-Regular;
        font-size: 26px;
        color: #999;
        letter-spacing: 0;
    }
</style>
